import sys
import pika

connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"
# create a task_queue queue
# param bool durable: Survive reboots of the broker :
channel.queue_declare(queue='task_queue', durable=True)

channel.basic_publish(exchange='',
                      routing_key='task_queue',
                      body=message,
                      properties=pika.BasicProperties(
                                 delivery_mode=2,  # make message persistent
                                 )
                    )
print(" [x] Sent %r" % message)
connection.close()